home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2002 #11 / Amiga Plus CD - 2002 - No. 11.iso / Tools / MorphOS / Epic4_mos / share / epic / script / netsplit.env < prev    next >
Encoding:
Text File  |  2002-10-28  |  3.9 KB  |  160 lines

  1. # NETSPLIT 7 - This script does it's best to suppress the excessive 
  2. # joins and signoffs due ONLY to netsplits.  It should pass regular
  3. # signoffs.   Need at least ircII2.2pre6
  4. # Version II  handles multiple channels. 
  5. # Version III ignores bogus signoff messages
  6. # Version IV  handles multiple splits.
  7. # Version V   handles multiple splits and ignores bogus signoff messages. also
  8. #             adds timestamps to split/join messages
  9. # Version VI  For ircII2.2pre8 and beyond. Uses encode() and decode() 
  10. # Version VII Fixed a problem with encode() and decode() and case
  11. #             sensitive channel names, + adding lformat()
  12. #
  13. # This one by Daemon
  14. # CONVERTED for ircII2.2pre8
  15. # Version V by poxaV (cgw@unt.edu), from Daemon's code
  16. # modified last 7-03-93
  17.  
  18. #shows the current time in HH:MM:SS format
  19. alias currtime @ function_return = strftime(%T)
  20.  
  21. # This function tests for bogus splits.
  22. alias isbogus {
  23.     if ([$3]) { @ function_return = 1 }
  24.     if (rmatch(.$1. $isbogus.pats *..*)) { @ function_return = 1 }
  25.     if (rmatch(.$2. $isbogus.pats *..*)) { @ function_return = 1 }
  26. }
  27.  
  28. # Add patterns.. like /boguspat *bonk* *thud* *haha*
  29. # that will NOT be treated as server names..
  30. alias boguspat ^assign isbogus.pats $isbogus.pats $0-;echo $0- added
  31.  
  32. # Next two are pretty obvious
  33. alias boguslist echo Pats: $isbogus.pats
  34. alias bogusclear ^assign -isbogus.pats;echo Bogus list clean
  35.  
  36. # If first word in Signoff contains a period then assume servername
  37. # and thus a a split.  Stash in assoc array.
  38. ON ^CHANNEL_SIGNOFF "% % %.% %.%" {
  39.     if (isbogus($1-)) 
  40.         { echo *** Quit: $1 \($0, $2-\) }
  41.         { ^netbroke $encode($tolower($0)) $encode($1) $encode($2).$encode($3) $2 $3 }
  42. }
  43.  
  44. # Stuff array. Tell us what server broke and set split flag.
  45. ^alias netbroke {
  46.     @ signcross[$2][$0][$1] = 1
  47.     @ signoffs[$0][$1] = [$2]
  48.     @ splittime[$2] = time()
  49.     if ( !isbroke[$2] )
  50.     {
  51.         xecho -level OPNOTES *** Netsplit at $currtime() \($3-\)
  52.         @ isbroke[$2] = 1
  53.         @ splitname[$2] = [$3-]
  54.     }
  55. }
  56.  
  57. # When a person joins a channel.. Check them against the array.
  58. # If they are in array, then remove silently.  Otherwards echo normally
  59. ON #^JOIN -10 * {
  60.     ^netjoined $encode($tolower($1)) $encode($0) $1 $0 $USERHOST()
  61. }
  62.  
  63. # Unset the split flag
  64. alias netjoined {
  65.     if ( signoffs[$0][$1] )
  66.     {
  67.         if ( isbroke[$signoffs[$0][$1]] )
  68.         {
  69.             xecho -level OPNOTES *** Netjoined at $currtime() \($splitname[$signoffs[$0][$1]]\)
  70.         }
  71.         ^assign -isbroke[$signoffs[$0][$1]]
  72.         ^assign -signcross[$signoffs[$0][$1]][$0][$1]
  73.         ^assign -signoffs[$0][$1]
  74.         @ rejoin = 1
  75.     }
  76. }
  77.  
  78. # Clear the array every 10 minutes to prevent excess garbage
  79. on #^timer 70 * netclean
  80.  
  81. alias netclean {
  82.     foreach splittime ii
  83.     {
  84.         foreach splittime.$ii jj
  85.         {
  86.             if ( time() - splittime[$ii][$jj] > 300 )
  87.             {
  88.                 foreach signcross.$(ii).$jj xx
  89.                 {
  90.                     foreach signcross.$(ii).$(jj).$xx yy
  91.                     {
  92.                         ^assign -signcross[$ii][$jj][$xx][$yy]
  93.                         ^assign -signoffs[$xx][$yy]
  94.                     }
  95.                 }
  96.                 ^assign -xx
  97.                 ^assign -yy
  98.                 ^assign -isbroke[$ii][$jj]
  99.                 ^assign -splitname[$ii][$jj]
  100.                 ^assign -splittime[$ii][$jj]
  101.             }
  102.         }
  103.     }
  104.     ^assign -ii
  105.     ^assign -jj
  106. }
  107.  
  108. alias netpurge {
  109.     purge isbroke
  110.     purge splitname
  111.     purge splittime
  112.     purge signcross
  113.     purge signoffs
  114. }
  115.  
  116. # If you want to suppress mode changes by servers.. (usually after a split)
  117. # then uncomment next line
  118. # ^on ^mode "%.%" #
  119.  
  120. # If you want to look an array.. Type /show <arrayname>
  121. # Lists keys and contents
  122. alias showsplit {
  123.     if ([$($0)]) {echo $0 $($0)}
  124.     foreach $0 ii
  125.     {
  126.         showsplit $0.$ii
  127.     }
  128. }
  129.  
  130. alias purge {
  131.     foreach $0 ii
  132.     {
  133.         purge $0.$ii
  134.     }
  135.     ^assign -ii
  136.     ^assign -$0
  137. }
  138.  
  139. alias wholeft {
  140.     foreach signoffs ii
  141.     {
  142.         foreach signoffs.$ii jj
  143.         {
  144.             echo $lformat(15 $decode($ii)) $lformat(10 $decode($jj)) $splitname[$signoffs[$ii][$jj]]
  145.         }
  146.     }
  147.     ^assign -ii
  148.     ^assign -jj
  149. }
  150.  
  151. # format and lformat differ from $[-num]var and $[num]var in that
  152. # They don't chop off the string if it is too long.
  153.  
  154. alias lformat {
  155.     @ IRCII.word = [$1-]
  156.     if (@IRCII.word < [$0]) 
  157.         { @ function_return = [$([$0]IRCII.word)] } 
  158.         { @ function_return = [$IRCII.word] } 
  159. }
  160.